package com.crealth.model;

import java.io.Serializable;

import com.alibaba.fastjson.JSONObject;

public class ConsumerPolicyModel implements Serializable {
	private static final long serialVersionUID = 61260L;
	
	private int id;
	private int consumerID;
	private int policyCompany;
	private int policyTime;
	private String yearPaySum;
	private int isFuxiao;
	private int policyPerson;
	
	public ConsumerPolicyModel() {
		consumerID = -1;
		policyCompany = -1;
		policyTime = -1;
		isFuxiao = -1;
		policyPerson = -1;
		yearPaySum = "";
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getConsumerID() {
		return consumerID;
	}
	public void setConsumerID(int consumerID) {
		this.consumerID = consumerID;
	}
	public int getPolicyCompany() {
		return policyCompany;
	}
	public void setPolicyCompany(int policyCompany) {
		this.policyCompany = policyCompany;
	}
	public int getPolicyTime() {
		return policyTime;
	}
	public void setPolicyTime(int policyTime) {
		this.policyTime = policyTime;
	}
	public String getYearPaySum() {
		return yearPaySum;
	}
	public void setYearPaySum(String yearPaySum) {
		this.yearPaySum = yearPaySum;
	}
	public int getIsFuxiao() {
		return isFuxiao;
	}
	public void setIsFuxiao(int isFuxiao) {
		this.isFuxiao = isFuxiao;
	}
	public int getPolicyPerson() {
		return policyPerson;
	}
	public void setPolicyPerson(int policyPerson) {
		this.policyPerson = policyPerson;
	}
	
	public void parseFromJson(JSONObject jsonData) {
		if (jsonData.containsKey("policyCom")) {
			this.policyCompany = jsonData.getIntValue("policyCom");
		}
		if (jsonData.containsKey("policyTime")) {
			this.policyTime = jsonData.getIntValue("policyTime");
		}
		if (jsonData.containsKey("yearPayMoney")) {
			this.yearPaySum = jsonData.getString("yearPayMoney");
		}
		if (jsonData.containsKey("isFuxiao")) {
			this.isFuxiao = jsonData.getIntValue("isFuxiao");
		}
		if (jsonData.containsKey("policyMan")) {
			this.policyPerson = jsonData.getIntValue("policyMan");
		}		
	}
	
	public JSONObject toJSONObject() {
		JSONObject jsonObj = new JSONObject();
		if (policyCompany >= 0) {
			jsonObj.put("policyCom", policyCompany);
		}
		if (policyTime >= 0) {
			jsonObj.put("policyTime", policyTime);
		}
		if (yearPaySum != null && yearPaySum.length() > 0) {
			jsonObj.put("yearPayMoney", yearPaySum);
		}
		if (isFuxiao >= 0) {
			jsonObj.put("isFuxiao", isFuxiao);
		}
		if (policyPerson >= 0) {
			jsonObj.put("policyMan", policyPerson);
		}
		
		return jsonObj;
	}
	
}
